﻿#region License
// (c) Garry McGlennon 2009
// 
// This project is made available under the Microsoft Public License (Ms-PL)
// Code is provided as is and with no warrenty – Use at your own risk
// 
// View the project and the latest code at http://dnpframework.codeplex.com/
// 
// All other rights reserved.
// 
// blog: www.dotNetProfessional.com/blog/
#endregion
using System;
using dnp.Framework.Database.DatabaseExplorer;

namespace dnp.DomainModeler
{
    public class RoutineSource : ISource
    {
        private Routine _source;
        private SourceColumnCollection _columns = new SourceColumnCollection();

        #region ISource Members

        public RoutineSource(Routine source)
        {
            _source = source;

            // Transfer the ColumnCollection to the new collection
            foreach (RoutineColumn c in _source.Columns)
                this.Columns.Add(c);
        }

        public Type SourceType
        {
            get { return _source.GetType(); }
        }

        object ISource.Instance
        {
            get { return _source; }
        }

        public Routine Instance
        {
            get { return _source; }
        }

        public string Name
        {
            get { return this.Instance.Name; }
        }

        public ExtendedPropertyCollection ExtendedProperties
        {
            get { return this.Instance.ExtendedProperties; }
        }

        public string FullName
        {
            get { return this.Instance.FullName; }
        }

        public string Definition
        {
            get { return ""; }
        }

        public SourceColumnCollection Columns
        {
            get { return _columns; }
        }
        public string Description
        {
            get { return this.Instance.Description; }
        }

        public string SafeFullName
        {
            get { return this.Instance.SafeFullName; }
        }
        #endregion
    }
}